class Observer {
    constructor(data) {
        this.walk(data)
    }
    walk(data) {
        if (!data || !typeof data === 'object') {
            return
        }
        Object.keys(data).forEach(key => {
            this.defineReactive(data, key, data[key])
        })

    }
    defineReactive(obj, key, value) {
        let that = this;
        this.walk(value)
        Object.defineProperty(obj, key, {
            enumerable: true,
            configurable: true,
            get() {
                return value
            },
            set(newValue) {
                if (newValue === value) {
                    return
                }
                this.walk(newValue)
            }

        })

    }
}